define([], function() {
    var Db = {
        get: function() {
            return openDatabase("auto", "1.0", "Glowna baza danych", 2 * 1024 * 1024);
        },
        getStorage: function() {
            return {
                storage: window.localStorage,
                get: function(name) {
                    var string = this.storage.getItem(name);
                    var obj = JSON.parse(string);
                    return obj;
                },
                set: function(name, json) {
                    json = this.clearArray(json);
                    var string = JSON.stringify(json);
                    this.storage.setItem(name, string);
                },
                clearArray: function(inputArray) {
                    if (Array.isArray(inputArray)) {
                        var json2 = [];
                        for (var i in inputArray) {
                            if (Array.isArray(inputArray[i])) {
                                json2.push(this.clearArray(inputArray[i]));
                            }
                            else if (inputArray[i] !== null) {
                                json2.push(inputArray[i]);
                            }
                        }
                        inputArray = json2;
                    }
                    return inputArray;
                }
            }
        }
    }

    return Db;
});